<?php echo get_header(); ?>
<form action="" method="get" id="category_index">
    <div class="row">
        <div class="col-lg-12">
            <div class="card">
                <div class="card-header">
                    <i class="fa fa-list-ul"></i> 分类管理
                </div>
                <div class="card-block">
                    <div class="p-b-1">
                        <a href="<?php echo url_for('/node/category.php?action=add'); ?>" class="btn btn-success btn-md"><i class="fa fa-plus"></i> 添加分类</a>
                    </div>
                    <table class="table table-hover table-outline mb-0 hidden-sm-down">
                        <thead class="thead-default">
                            <tr>
                                <th>                                   
                                    <input type="checkbox" id="chk-all">
                                </th>
                                <th>名称</th>
                                <th>操作</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php foreach ($categories as $cat) { ?>
                                <tr>
                                    <td width="10px"><input type="checkbox" class="chk-row"  name="category[id]" value="<?php echo $cat->category_id; ?>" />
                                          </td>
                                    <td style="padding-left: <?php echo ($cat->depth - 1) * 20; ?>px"><a href="<?php
                                        echo url_for('/node/category.php', ['action' => 'edit', 'id' => $cat->category_id]);
                                        ?>"><b><?php echo $cat->title; ?></b></a></td>

                                    <td width="20%">

                                        <a href="<?php echo url_for('/node/category.php', ['action' => 'edit', 'id' => $cat->category_id]); ?>" ><i class="fa fa-edit"></i> 编辑</a>
                                        <a href="<?php echo url_for('/node/category.php', ['action' => 'delete', 'id' => $cat->category_id]); ?>"><i class="fa fa-trash"></i> 删除</a>


                                    </td>
                                </tr>
                            <?php } ?>



                        </tbody>
                    </table>
                    <?php echo $paginator->render(7, 'pagination pagination-sm m-top-none pull-right'); ?>
                </div>


            </div>
        </div>
    </div>

</form>
<?php Lg\View\JsBlock::begin(Lg\View\Asset::BODY_END); ?>
<script>
    $(function () {
        $('#chk-all').click(function () {
            if ($(this).is(':checked')) {
                $('#dataTable').find('.chk-row').each(function () {
                    $(this).prop('checked', true);
                    $(this).parent().parent().parent().addClass('selected');
                });
            } else {
                $('#dataTable').find('.chk-row').each(function () {
                    $(this).prop('checked', false);
                    $(this).parent().parent().parent().removeClass('selected');
                });
            }
        });
    });
</script>
<?php Lg\View\JsBlock::end(); ?>
<?php echo get_footer(); ?>
